// ==UserScript==
// @name		大家的幻想乡Unity脚本
// @namespace	http://www.mapaler.com/
// @description	大家的幻想乡自动做日常脚本
// @match		*://mapaler.github.io/DaJiaDeHuanXiangXiang-Skin/bot.html
// @match		*://mapaler.gitee.io/dajiadehuanxiangxiang-skin/bot.html
// @match		file:///*/DaJiaDeHuanXiangXiang-Skin/bot.html
// @version		2.0.16
// @require		https://cdn.staticfile.org/pako/1.0.10/pako.min.js
// @require		https://cdn.staticfile.org/crypto-js/3.1.9/crypto-js.min.js
// @grant		GM_xmlhttpRequest
// @grant		GM_getValue
// @grant		GM_setValue
//-@grant		GM_deleteValue
//-@grant		GM_listValues
// @grant       GM_addStyle
// @connect		121.40.19.137
// @connect		121.40.238.160
// @connect		121.43.196.228
// @connect		121.43.197.25
// ==/UserScript==


(function() {
	'use strict';

/* 刷图数据解释
mapid是进入的地图ID。
difficulty是难度级别，1为简单，2为普通，3为困难。
groupid是使用第几个编组。
or  是分歧路径id
battledata储存每面的战斗数据，player是人物数据，equipmentid是使用的道具id。
cardid是人物id，column代表横向站位，0代表防御位，1代表攻击位，2代表支援位；
row代表纵向站位，防御位和支援位正常只有1、3，攻击位正常只有0、2、4，其中2是队长。
也就是说 column:1 ,row:4 代表队长位。
不同面需要不同站位时，就可以设定多个内容，每面人物必须一致。
地图面数多于battledata数据的时候，会自动使用最后一个战斗数据进入战斗。
如果一关战斗数据exit：为true代表该关就退出该地图，所以必须把前面需要进入的每面的数据写好。
*/
const batchArr = [{
		mapid: "M100011",
		difficulty: 2,
		groupid: 5, //毛玉栖息地⭐️ 单刷绒毛
		or: 0, //是否是分歧路径地图
		battledata: [{
			player: [
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
			],
			equipmentid: ""
		}, ]
	},
	{
		mapid: "M100012",
		difficulty: 2,
		groupid: 5, //野兽徘徊的道路⭐️ 单刷绒毛
		battledata: [{
			player: [
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
			]
		}]
	},
	{
		mapid: "M100013",
		difficulty: 2,
		groupid: 5, //博丽神社山脚⭐️⭐️⭐️⭐️ 单刷博丽护符、封魔针
		battledata: [{
			player: [
				{ cardid: "ATH0027", column: 1, row: 0 }, //莉格露·奈特巴格，攻击位
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100021",
		difficulty: 2,
		groupid: 5, //郊外的农田   ⭐️ 刷妖精契约
		battledata: [{
			player: [
				{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
			]
		}]
	},
	{
		mapid: "M100022",
		difficulty: 2,
		groupid: 5, //战车坟场    ⭐️⭐️⭐️⭐️ 刷金属块、精密零件
		battledata: [{
			player: [
				{ cardid: "ATHZ014", column: 1, row: 4 }, //冈崎梦美，攻击位，精密零件
				{ cardid: "ATH0063", column: 2, row: 1 }, //古明地恋，支援位，菜刀
			]
		}]
	},
	{
		mapid: "M100023",
		difficulty: 2,
		groupid: 5, //草根妖怪结社  ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷二级材料
		battledata: [{
			player: [
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
				{ cardid: "ATH0028", column: 1, row: 0 }, //米斯蒂娅·萝蕾拉，攻击位
				{ cardid: "ATH0019", column: 2, row: 1 }, //莉莉卡·普莉兹姆利巴，支援位，加暴伤
				{ cardid: "ATH0017", column: 2, row: 0 }, //露娜萨·普莉兹姆利巴，支援位，加暴击
			]
		}]
	},
	{
		mapid: "M100031",
		difficulty: 2,
		groupid: 5, //河童栖息地   ⭐️⭐️⭐️ 刷零件、精密零件
		battledata: [{
			player: [
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
			]
		}]
	},
	{
		mapid: "M100041",
		difficulty: 2,
		groupid: 5, //天狗的前哨   ⭐️⭐️ 刷白狼天狗徽记
		battledata: [{
			player: [
				{ cardid: "ATH0035", column: 1, row: 4 }, //射命丸文，攻击位，戍卫套装
			]
		}]
	},
	{
		mapid: "M100042",
		difficulty: 2,
		groupid: 5, //丰收的果林   ⭐️⭐️⭐️ 刷苹果、红苕
		battledata: [{
			player: [
				{ cardid: "ATH0034", column: 1, row: 4 }, //藤原妹红，攻击位，烤红薯
			]
		}]
	},
	{
		mapid: "M100043",
		difficulty: 2,
		groupid: 5, //天狗的村落   ⭐️⭐️⭐️⭐️ 刷鸦天狗的羽毛
		battledata: [{
			player: [
				{ cardid: "ATH0072", column: 1, row: 2 }, //姬海棠果，队长位，记者服
				{ cardid: "ATH0080", column: 0, row: 1 }, //秦心，防御位，天狗面具
			]
		}]
	},
	{
		mapid: "M100044",
		difficulty: 2,
		groupid: 5, //妖怪山山阴   ⭐️⭐️⭐️⭐️ 刷苹果、红苕、煤炭
		battledata: [{
			player: [
				{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
			]
		}]
	},
	{
		mapid: "M100051",
		difficulty: 2,
		groupid: 5, //守矢神社    ⭐️⭐️⭐️⭐️ 刷守失护符
		battledata: [{
			player: [
				{ cardid: "ATH0001", column: 1, row: 4 }, //博丽灵梦，攻击位，阴阳玉
			]
		}]
	},
	{
		mapid: "M100052",
		difficulty: 2,
		groupid: 5, //御柱的墓场   ⭐️⭐️⭐️⭐️⭐️ 刷守失护符
		battledata: [{
			player: [
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
			]
		}]
	},
	{
		mapid: "M100053",
		difficulty: 2,
		groupid: 5, //月球基地    ⭐️⭐️⭐️⭐️⭐️ 刷经验、四叶草
		battledata: [{
			player: [
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
			]
		}]
	},
	{
		mapid: "M100061",
		difficulty: 2,
		groupid: 5, //魔法之森⭐️ 单刷蘑菇
		battledata: [{
			player: [
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
			]
		}]
	},
	{
		mapid: "M100062",
		difficulty: 2,
		groupid: 5, //雾雨魔法店   ⭐️⭐️⭐️ 刷蘑菇、星星碎片
		battledata: [{
			player: [
				{ cardid: "ATH0008", column: 1, row: 0 }, //帕秋莉·诺蕾姬，攻击位，魔法使的帽子、魔女服
				{ cardid: "ATH0015", column: 1, row: 4 }, //爱丽丝·玛格特洛依德，攻击位，魔法使的帽子、魔女服
			]
		}]
	},
	{
		mapid: "M100063",
		difficulty: 2,
		groupid: 5, //爱丽丝宅邸   ⭐️⭐️⭐️ 刷布料、魔法丝线
		battledata: [{
			player: [
				{ cardid: "ATH0002", column: 1, row: 4 }, //雾雨魔理沙，攻击位，魔导书
				{ cardid: "ATH0008", column: 1, row: 0 }, //帕秋莉·诺蕾姬，攻击位，魔导书
			]
		}]
	},
	/*
	{mapid:"M100063",difficulty:3,groupid:5, //爱丽丝宅邸【困难】⭐️⭐️⭐️ 虫子（不在队长位）、橙、老鼠、奥莲姬、16夜  刷魔法石、魔女服
		battledata:[{player:[
			{cardid:"ATH0001",column:1,row:0}, //博丽灵梦
			{cardid:"ATH0007",column:1,row:1}, //小恶魔
			{cardid:"ATH0056",column:1,row:4}, //琪斯美
			{cardid:"ATH0064",column:2,row:1}, //老鼠，支援位
		]}]
	},
	*/
	{
		mapid: "M100063",
		difficulty: 2,
		groupid: 5, //魔力浓郁的深处   ⭐️⭐️⭐️⭐️⭐️ 刷蘑菇、星星碎片
		battledata: [{
			player: [
				{ cardid: "ATH0002", column: 1, row: 4 }, //雾雨魔理沙，攻击位，阵笠
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100071",
		difficulty: 2,
		groupid: 5, //黑暗森林     ⭐️⭐️ 单刷绒毛
		battledata: [{
			player: [
				{ cardid: "ATH0005", column: 1, row: 4 }, //琪露诺，攻击位，罐装幽灵
			]
		}]
	},
	/*
	{mapid:"M100072",difficulty:2,groupid:5, //雾之湖     ⭐️⭐️⭐️ 刷妖精契约、完美冰晶
		battledata:[{player:[
			{cardid:"ATH0047",column:1,row:4}, //洩矢诹访子，攻击位，刨冰
		]}]
	},
	*/
	{
		mapid: "M100072",
		difficulty: 3,
		groupid: 5, //雾之湖【困难】    ⭐️⭐️⭐️ 刷妖精契约、完美冰晶
		battledata: [{
			player: [
				{ cardid: "ATH0003", column: 1, row: 4 }, //露米娅，攻击位，契约
				{ cardid: "ATH0047", column: 1, row: 0 }, //洩矢诹访子，攻击位，刨冰
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100081",
		difficulty: 2,
		groupid: 5, //红魔馆前院 ⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷吸血鬼套装
		battledata: [{
			player: [
				{ cardid: "ATHZ026", column: 1, row: 0 }, //梦子，攻击位，匕首
				{ cardid: "ATH0096", column: 2, row: 1 }, //稗田阿求，支援位，伸缩拳击手枪
			]
		}]
	},
	/*
	{mapid:"M100081",difficulty:3,groupid:5, //红魔馆前院【困难】 ⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷吸血鬼套装
		battledata:[{player:[
			{cardid:"ATH0001",column:1,row:4}, //博丽灵梦
			{cardid:"ATH0004",column:1,row:0}, //大妖精，攻击位
			{cardid:"ATH0064",column:2,row:1}, //老鼠，支援位
		]}]
	},
	*/
	{
		mapid: "M100082",
		difficulty: 3,
		groupid: 5, //图书馆【困难】⭐️⭐️⭐️⭐️ 刷魔法石
		battledata: [{
			player: [
				{ cardid: "ATH0002", column: 1, row: 0 }, //雾雨魔理沙，攻击位，水晶球
				{ cardid: "ATH0015", column: 1, row: 4 }, //爱丽丝·玛格特洛依德，攻击位，水晶球
				{ cardid: "ATH0019", column: 2, row: 1 }, //莉莉卡·普莉兹姆利巴，支援位，加暴伤
				{ cardid: "ATH0017", column: 2, row: 0 }, //露娜萨·普莉兹姆利巴，支援位，加暴击
			]
		}]
	},
	/*
	{mapid:"M100083",difficulty:2,groupid:5, //绯红的大厅   ⭐️⭐️⭐️⭐️⭐️ 刷命运之石
		battledata:[{player:[
			{cardid:"ATH0027",column:1,row:4}, //莉格露·奈特巴格，攻击位
		]}]
	},
	*/
	{
		mapid: "M100083",
		difficulty: 3,
		groupid: 5, //绯红的大厅【困难】⭐️⭐️⭐️⭐️⭐️ 刷战斗女仆装、吸血鬼套装
		battledata: [{
			player: [
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
				{ cardid: "ATH0028", column: 1, row: 0 }, //米斯蒂娅·萝蕾拉，攻击位
				{ cardid: "ATH0017", column: 2, row: 0 }, //露娜萨·普莉兹姆利巴，支援位，加暴击
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100084",
		difficulty: 3,
		groupid: 5, //地下室【困难】⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️  刷吸血鬼套装
		battledata: [{
			player: [
				{ cardid: "ATH0063", column: 1, row: 4 }, //古明地恋，攻击位，糖果
			]
		}]
	},
	{
		mapid: "M100091",
		difficulty: 2,
		groupid: 5, //迷途之家    ⭐️⭐️⭐️⭐️ 刷金属块、核燃料
		battledata: [{
			player: [
				{ cardid: "ATHZ017", column: 1, row: 4 }, //奥莲姬，攻击位，体操服
			]
		}]
	},
	{
		mapid: "M100092",
		difficulty: 2,
		groupid: 5, //境界裂口    ⭐️⭐️⭐️⭐️⭐️⭐️ 刷金属块、核燃料
		battledata: [{
			player: [
				{ cardid: "ATH0069", column: 1, row: 4 }, //圣白莲，攻击位，发动机
			]
		}]
	},
	{
		mapid: "M100093",
		difficulty: 2,
		groupid: 5, //境界内部    ⭐️⭐️⭐️⭐️⭐️⭐️ 刷路标
		battledata: [{
			player: [
				{ cardid: "ATH0021", column: 1, row: 4 }, //西行寺幽幽子，攻击位，折叠伞
				{ cardid: "ATH0100", column: 2, row: 1 }, //玛艾露贝莉·赫恩，支援位，女仆装
			]
		}]
	},
	{
		mapid: "M100102",
		difficulty: 2,
		groupid: 5, //白玉楼阶梯   ⭐️⭐️⭐️⭐️⭐️ 刷心眼，困难不爆心眼
		battledata: [{
			player: [
				{ cardid: "ATHZ008", column: 1, row: 4 }, //明罗，攻击位，太刀
			]
		}]
	},
	/*
	{mapid:"M100103",difficulty:2,groupid:5, //白玉楼     ⭐️⭐️⭐️⭐️⭐️⭐️ 刷亡灵之书
		battledata:[{player:[
			{cardid:"ATH0004",column:1,row:4}, //大妖精，攻击位
			{cardid:"ATH0064",column:2,row:1}, //老鼠，支援位
		]}]
	},
	*/
	{
		mapid: "M100103",
		difficulty: 3,
		groupid: 5, //白玉楼【困难】⭐️⭐️⭐️⭐️⭐️⭐️ 刷西行妖树枝
		battledata: [{
			player: [
				{ cardid: "ATHZ008", column: 1, row: 4 }, //明罗，攻击位，肋差
				{ cardid: "ATH0023", column: 1, row: 0 }, //八云紫，攻击位，西行妖树枝，御所车画屏
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	/*
	{mapid:"M100111",difficulty:2,groupid:5, //迷途竹林    ⭐️⭐️⭐️⭐️ 刷四叶草
		battledata:[{player:[
			{cardid:"ATH0004",column:1,row:4}, //大妖精，攻击位
		]}]
	},
	*/
	{
		mapid: "M100083",
		difficulty: 3,
		groupid: 5, //迷途竹林【困难】⭐️⭐️⭐️⭐️
		battledata: [{
			player: [
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
				{ cardid: "ATH0028", column: 1, row: 0 }, //米斯蒂娅·萝蕾拉，攻击位
				{ cardid: "ATH0017", column: 2, row: 0 }, //露娜萨·普莉兹姆利巴，支援位，加暴击
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100112",
		difficulty: 3,
		groupid: 5, //竹林小屋️️【困难】  ⭐️⭐️⭐️⭐️⭐️ 刷不死鸟羽毛
		battledata: [{
			player: [
				{ cardid: "ATH0033", column: 1, row: 4 }, //蓬莱山辉夜，攻击位，羽毛
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	/*
	{mapid:"M100113",difficulty:2,groupid:5, //永远亭     ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷不朽的数树枝
		battledata:[{player:[
			{cardid:"ATH0004",column:1,row:4}, //大妖精，攻击位
		]}]
	},
	*/
	{
		mapid: "M100113",
		difficulty: 3,
		groupid: 5, //永远亭【困难】⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷月饼、路由器
		battledata: [{
			player: [
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
				{ cardid: "ATH0028", column: 1, row: 0 }, //米斯蒂娅·萝蕾拉，攻击位
				{ cardid: "ATH0017", column: 2, row: 0 }, //露娜萨·普莉兹姆利巴，支援位，加暴击
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100121",
		difficulty: 3,
		groupid: 5, //无名之丘【困难】⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️️
		battledata: [{
			player: [
				{ cardid: "ATH0032", column: 1, row: 4 }, //八意永琳，攻击位，遗忘药水
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	/*
	{mapid:"M100122",difficulty:2,groupid:5, //太阳花田   ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷太阳花
		battledata:[{player:[
			{cardid:"ATH0004",column:1,row:4}, //大妖精，攻击位
		]}]
	},
	*/
	{
		mapid: "M100122",
		difficulty: 3,
		groupid: 5, //太阳花田【困难】⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️
		battledata: [{
			player: [
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
				{ cardid: "ATH0028", column: 1, row: 0 }, //米斯蒂娅·萝蕾拉，攻击位
				{ cardid: "ATH0017", column: 2, row: 0 }, //露娜萨·普莉兹姆利巴，支援位，加暴击
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100132",
		difficulty: 2,
		groupid: 5, //旧都       ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷石樱
		battledata: [{
			player: [
				{ cardid: "ATH0026", column: 1, row: 4 }, //伊吹萃香，攻击位，清扫机
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100133",
		difficulty: 2,
		groupid: 5, //地灵殿     ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷皮鞭
		battledata: [{
			player: [
				{ cardid: "ATH0010", column: 1, row: 4 }, //蕾米莉亚·斯卡蕾特，攻击位，隐身斗篷
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100141",
		difficulty: 2,
		groupid: 5, //命莲寺前门     ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷？
		battledata: [{
			player: [
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
			]
		}]
	},
	{
		mapid: "M100142",
		difficulty: 2,
		groupid: 5, //圣辇船     ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷飞仓碎片
		battledata: [{
			player: [
				{ cardid: "ATH0004", column: 1, row: 4 }, //大妖精，攻击位
			]
		}]
	},
	{
		mapid: "M100143",
		difficulty: 2,
		groupid: 5, //命莲寺     ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷佛教经卷
		battledata: [{
			player: [
				{ cardid: "ATH0078", column: 1, row: 4 }, //丰聪耳神子，攻击位，大悲咒
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100151",
		difficulty: 2,
		groupid: 5, //命莲寺墓地 ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷天书符咒
		battledata: [{
			player: [
				{ cardid: "ATH0001", column: 1, row: 4 }, //博丽灵梦，攻击位，封魔针
			]
		}]
	},
	{
		mapid: "M100152",
		difficulty: 2,
		groupid: 5, //梦殿大祀庙 ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷威严的笏板
		battledata: [{
			player: [
				{ cardid: "ATH0069", column: 1, row: 0 }, //圣白莲，桃木剑
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100161",
		difficulty: 2,
		groupid: 5, //梦境月都   ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷隐身斗篷，幸运水手服
		battledata: [{
			player: [
				{ cardid: "ATH0098", column: 1, row: 0 }, //本居小铃
				{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100162",
		difficulty: 2,
		groupid: 5, //月面       ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷女王套装
		battledata: [{
			player: [
				{ cardid: "ATH0099", column: 1, row: 0 }, //宇佐见莲子
				{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100163",
		difficulty: 2,
		groupid: 5, //月之都     ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷左扇
		battledata: [{
			player: [
				{ cardid: "ATH0023", column: 1, row: 0 }, //八云紫，攻击位，路由器
				{ cardid: "ATH0031", column: 1, row: 4 }, //铃仙·优昙华院·因幡，攻击位，狙击步枪
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
			]
		}]
	},
	{
		mapid: "M100172",
		difficulty: 2,
		groupid: 5, //辉针城     ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 橙、蜘蛛、老鼠、刷弹慕天邪鬼装备
		battledata: [{
			player: [
				{ cardid: "ATH0057", column: 1, row: 0 }, //黑谷山女，攻击位
				{ cardid: "ATH0103", column: 1, row: 1 }, //铃瑚，攻击位
				{ cardid: "ATH0040", column: 1, row: 4 }, //秋静叶，攻击位
				{ cardid: "ATH0064", column: 2, row: 1 }, //老鼠，支援位
				{ cardid: "ATHZ019", column: 2, row: 3 }, //艾丽，支援位
			]
		}]
	},

	/*
	//万圣节活动
	{mapid:"HHA1003",difficulty:3,groupid:5, //妖怪步行街【困难】     ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷万圣节糖果
		battledata:[{player:[
			{cardid:"ATH0057",column:1,row:0}, //黑谷山女，攻击位
			{cardid:"ATH0103",column:1,row:1}, //铃瑚，攻击位
			{cardid:"ATH0090",column:1,row:4}, //桑尼米尔克，攻击位
			{cardid:"ATH0064",column:2,row:1}, //老鼠，支援位
			{cardid:"ATHZ019",column:2,row:1}, //艾丽，支援位
		]}]
	},
	{mapid:"HHA1004",difficulty:3,groupid:5, //僵尸王墓地【困难】     ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷万圣节糖果
		battledata:[{player:[
			{cardid:"ATH0057",column:1,row:0}, //黑谷山女，攻击位
			{cardid:"ATH0103",column:1,row:1}, //铃瑚，攻击位
			{cardid:"ATH0091",column:1,row:4}, //露娜切云德，攻击位
			{cardid:"ATH0064",column:2,row:1}, //老鼠，支援位
			{cardid:"ATHZ019",column:2,row:1}, //艾丽，支援位
		]}]
	},
	{mapid:"HHA1005",difficulty:3,groupid:5, //恶妖萦绕之街【困难】     ⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️⭐️️️️️️ 刷万圣节糖果
		battledata:[{player:[
			{cardid:"ATH0057",column:1,row:0}, //黑谷山女，攻击位
			{cardid:"ATH0103",column:1,row:1}, //铃瑚，攻击位
			{cardid:"ATH0092",column:1,row:4}, //斯塔萨菲雅，攻击位
			{cardid:"ATH0064",column:2,row:1}, //老鼠，支援位
			{cardid:"ATHZ019",column:2,row:1}, //艾丽，支援位
		]}]
	},
	*/

	//{mapid:"H100004",difficulty:3,groupid:5,data:"ATH0027,1,4;"}, //年兽出没的农田（郊外的农田）【困难】⭐️⭐️⭐️ 刷妖精契约
];
/* 任务数据
questsid是任务的ID。
type是任务类型，原版10是杀怪，11是特殊队伍要求杀怪，12是要求与人物一起杀怪，20是过图，22是要求与人物一起过图，30是举办宴会，31是特殊人物举办宴会，40是完成锻造，50是赠送
自动程序直接简化为10-29的都算战斗，30是宴会，40是锻造，50是赠送

data是具体的操作过程，分别介绍
杀怪或刷图时，data数组每个元素代表一个地图，写法见上方刷图数据解释，如需重复刷同一个地图，需重复添加多个数组元素即可。
宴请妖怪时，cardid是人物ID，type 1-3表示小中大宴。每次执行会先执行一次快速筹备、开始宴会，以清空之前可能的宴会。然后按照设置筹备-快速筹备-开始宴会-领取任务奖励。因此建议不要使用这一模式，请手动。
赠送物品时，cardid是被赠送人id，equipmentid是物品id，count是数量
锻造时，blueprintid是锻造id
*/
const QuestsArr = [
	{
		questsid: 3000006, //宴请妖怪 完成一次【宴会】
		type: 30,
		data: [
			{ cardid: "ATHZH01", type: 1 }, //年兽 小宴
		],
	},
	{
		questsid: 3000001, //日常清扫 退治【毛玉】10只
		type: 10,
		data: [{
				mapid: "M100011",
				difficulty: 2,
				groupid: 5, //毛玉栖息地
				battledata: [{
					player: [
						{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
					],
					equipmentid: ""
				}, ]
			},
			{
				mapid: "M100011",
				difficulty: 2,
				groupid: 5, //毛玉栖息地
				battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
			},
		],
	},
	{
		questsid: 3000002, //清扫野道 退治【野兽】10只
		type: 10,
		data: [{
				mapid: "M100012",
				difficulty: 2,
				groupid: 5, //野兽徘徊的道路
				battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
			},
			{
				mapid: "M100012",
				difficulty: 2,
				groupid: 5, //野兽徘徊的道路
				battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
			},
		],
	},
	{
		questsid: 3000003, //退治妖精 退治【小妖精】10只
		type: 10,
		data: [{
				mapid: "M100072",
				difficulty: 2,
				groupid: 5, //雾之湖
				battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
			},
			{
				mapid: "M100072",
				difficulty: 2,
				groupid: 5, //雾之湖
				battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
			},
		],
	},
	{
		questsid: 3000004, //丰收的秘密 前往【丰收的果林】
		type: 10,
		data: [{
			mapid: "M100042",
			difficulty: 2,
			groupid: 5, //丰收的果林
			battledata: [{ player: [{ cardid: "ATH0016", column: 1, row: 4 }] }] //莉莉白
		}, ],
	},
	{
		questsid: 3000005, //绯闻照片 退治【天狗的村落】的【射命丸文】
		type: 10,
		data: [{
			mapid: "M100043",
			difficulty: 2,
			groupid: 5, //天狗的村落
			battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
		}, ],
	},
	{
		questsid: 3000007, //妖精的宣战 退治【郊外的农田】的【桑尼米尔克】
		type: 10,
		data: [{
			mapid: "M100021",
			difficulty: 2,
			groupid: 5, //郊外的农田
			battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
		}, ],
	},
	{
		questsid: 3000008, //朋友很少 找【爱丽丝·玛格特洛依德】完成一次【裁缝】
		type: 40,
		data: [
			{ blueprintid: 40011, }, //防具制造
		],
	},
	{
		questsid: 3000009, //噪音扰民 退治【战车坟场】的【战车】5辆
		type: 10,
		data: [{
			mapid: "M100022",
			difficulty: 2,
			groupid: 5, //战车坟场
			battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
		}, ],
	},
	{
		questsid: 3000010, //拯救青蛙 前往【雾之湖】教训一下【琪露诺】
		type: 10,
		data: [{
			mapid: "M100072",
			difficulty: 2,
			groupid: 5, //雾之湖
			battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
		}, ],
	},
	{
		questsid: 3000011, //回收绒毛 赠送【稗田阿求】一批【绒毛】
		type: 50,
		data: [
			{ cardid: "ATH0096", equipmentid: 41101, count: 1, }, //绒毛x1
		],
	},
	{
		questsid: 3000012, //回收蘑菇 赠送【稗田阿求】一批【蘑菇】
		type: 50,
		data: [
			{ cardid: "ATH0096", equipmentid: 43101, count: 1, }, //蘑菇x1
		],
	},
	{
		questsid: 3000013, //回收矿石 赠送【稗田阿求】一批【矿石】
		type: 50,
		data: [
			{ cardid: "ATH0096", equipmentid: 42201, count: 1, }, //矿石x1
		],
	},
	//3000014, //【日常】 回收木材 赠送【稗田阿求】一批【木材】
	//3000015, //【日常】 书店闹鬼 赠送【本居小铃】一些【博丽符札】
	{
		questsid: 3000016, //丢失的宝塔 与【纳兹琳】一同前往【境界内部（普通）】
		type: 10,
		data: [{
			mapid: "M100093",
			difficulty: 2,
			groupid: 5, //境界内部（普通）
			battledata: [{
				player: [
					{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
					{ cardid: "ATH0064", column: 2, row: 1 }, //纳兹琳，支援位
				]
			}]
		}, ],
	},
	{
		questsid: 3000017, //拜访图书馆 与【古明地觉】一同前往【图书馆】
		type: 10,
		data: [{
			mapid: "M100082",
			difficulty: 3,
			groupid: 5, //图书馆（困难）
			battledata: [{
				player: [
					{ cardid: "ATH0060", column: 1, row: 4 }, //古明地觉，攻击位
					{ cardid: "ATH0028", column: 1, row: 0 }, //米斯蒂娅·萝蕾拉，攻击位
					{ cardid: "ATH0027", column: 2, row: 1 }, //莉格露·奈特巴格，支援位，追击
					{ cardid: "ATH0017", column: 2, row: 0 }, //露娜萨·普莉兹姆利巴，支援位，加暴击
				]
			}]
		}, ],
	},
	{
		questsid: 3000018, //传染病 与【上白泽慧音】一同前往【黑暗风穴】
		type: 10,
		data: [{
			mapid: "M100131",
			difficulty: 2,
			groupid: 5, //黑暗风穴
			battledata: [{
				player: [
					{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
					{ cardid: "ATH0029", column: 1, row: 0 }, //上白泽慧音，攻击位
				]
			}]
		}, ],
	},
	{
		questsid: 3000019, //蓬莱的药店 完成一次【制药】
		type: 40,
		data: [
			{ blueprintid: 60001, }, //药剂练成
		],
	},
	{
		questsid: 3000020, //代理寻遗 击败【纳兹琳】
		type: 10,
		data: [{
			mapid: "M100141",
			difficulty: 2,
			groupid: 5, //命莲寺前门
			battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
		}, ],
	},
	{
		questsid: 3000021, //不明飞行物（N） 带【封兽鵺】前往【圣辇船】（N）
		type: 10,
		data: [{
			mapid: "M100142",
			difficulty: 2,
			groupid: 5, //圣辇船（普通）
			battledata: [{
				player: [
					{ cardid: "ATH0070", column: 1, row: 4 }, //封兽鵺，攻击位
					{ cardid: "ATH0027", column: 1, row: 0 }, //莉格露·奈特巴格，攻击位
				]
			}]
		}, ],
	},
	{
		questsid: 3000022, //吓人的僵尸 击败【墓地】的【宫古芳香】
		type: 10,
		data: [{
			mapid: "M100151",
			difficulty: 2,
			groupid: 5, //命莲寺墓地
			battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
		}, ],
	},
	{
		questsid: 3000023, //废旧道具回收 击败8只【唐伞】
		type: 10,
		data: [{
			mapid: "M100151",
			difficulty: 2,
			groupid: 5, //命莲寺墓地
			battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
		}, ],
	},
	{
		questsid: 3000024, //毒性测试 带【八意永琳】前往【无名之丘】
		type: 10,
		data: [{
			mapid: "M100121",
			difficulty: 2,
			groupid: 5, //无名之丘
			battledata: [{
				player: [
					{ cardid: "ATH0032", column: 1, row: 0 }, //八意永琳，攻击位
				]
			}]
		}, ],
	},
	{
		questsid: 3000025, //威严交流（N） 带【蕾米莉亚】前往【地灵殿】（N）
		type: 10,
		data: [{
			mapid: "M100133",
			difficulty: 2,
			groupid: 5, //地灵殿（普通）
			battledata: [{
				player: [
					{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
					{ cardid: "ATH0010", column: 1, row: 0 }, //蕾米莉亚，攻击位
				]
			}]
		}, ],
	},
	{
		questsid: 3000026, //杏黄纸 赠送【霍青娥】一个【博丽符札】和一个【守矢护符】
		type: 50,
		data: [
			{ cardid: "ATH0075", equipmentid: 10001, count: 1, }, //博丽符札x1
			//{cardid:"ATH0075",equipmentid:50003,count:1,}, //守矢护符x1
		],
	},
	{
		questsid: 3000027, //圣辇船维护 赠送【村纱水蜜】2份【木材】
		type: 50,
		data: [
			{ cardid: "ATH0067", equipmentid: 42101, count: 2, }, //木材x2
		],
	},
	{
		questsid: 3000028, //无限增殖的头 退治6个【赤蛮奇的头】
		type: 10,
		data: [{
			mapid: "M100023",
			difficulty: 2,
			groupid: 5, //草根妖怪结社（普通）
			battledata: [{
				player: [
					{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
					{ cardid: "ATH0028", column: 1, row: 0 }, //米斯蒂娅·萝蕾拉，攻击位
					{ cardid: "ATH0019", column: 2, row: 1 }, //莉莉卡·普莉兹姆利巴，支援位，加暴伤
					{ cardid: "ATH0017", column: 2, row: 0 }, //露娜萨·普莉兹姆利巴，支援位，加暴击
				]
			}]
		}, ],
	},
	{
		questsid: 3000029, //吔团变得更强 赠送【铃湖】两份【团子】
		type: 50,
		data: [
			{ cardid: "ATH0103", equipmentid: 30005, count: 2, }, //团子x2
		],
	},
	{
		questsid: 3000030, //融入新集体 与【克劳恩皮丝】一同前往【郊外的农田】
		type: 22,
		data: [{
			mapid: "M100021",
			difficulty: 2,
			groupid: 5, //郊外的农田（普通）
			battledata: [{ player: [{ cardid: "ATH0106", column: 1, row: 4 }] }] //克劳恩皮丝，攻击位
		}, ],
	},
	{
		questsid: 3000031, //只是一个平凡的母亲 前往【爱丽丝宅邸】
		type: 20,
		data: [{
			mapid: "M100063",
			difficulty: 2,
			groupid: 5, //爱丽丝宅邸（普通）
			battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
		}, ],
	},
	{
		questsid: 3000032, //切磋剑技 与【明罗】一同前往【白玉楼阶梯】
		type: 22,
		data: [{
			mapid: "M100102",
			difficulty: 2,
			groupid: 5, //白玉楼阶梯（普通）
			battledata: [{
				player: [
					{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
					{ cardid: "ATHZ008", column: 2, row: 1 }, //明罗，支援位
				]
			}]
		}, ],
	},
	{
		questsid: 3000033, //收集面具 赠送【秦心】一张【天狗面具】
		type: 50,
		data: [
			{ cardid: "ATH0080", equipmentid: 20016, count: 1, }, //天狗面具x1
		],
	},
	{
		questsid: 3000034, //为复活所做的准备 赠送【魅魔】一把【扫帚】
		type: 50,
		data: [
			{ cardid: "ATHZ002", equipmentid: 10002, count: 1, }, //扫帚x1
		],
	},
	{
		questsid: 3000035, //“美味”的蛋糕 赠送【幻月】一份【黑暗料理】
		type: 50,
		data: [
			{ cardid: "ATHZ021", equipmentid: 60000, count: 1, }, //黑暗料理x1
		],
	},
	{
		questsid: 3000036, //美味的蛋糕！ 赠送【梦月】3个【西行妖的花瓣】
		type: 50,
		data: [
			{ cardid: "ATHZ020", equipmentid: 50020, count: 3, }, //西行妖的花瓣x3
		],
	},
	{
		questsid: 3000037, //前往幻想乡的通路 击败【梦境月都】的【哆来咪·苏伊特】
		type: 20,
		data: [{
			mapid: "M100161",
			difficulty: 2,
			groupid: 5, //梦境月都（普通）
			battledata: [{
				player: [
					{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
					{ cardid: "ATH0064", column: 2, row: 1 }, //纳兹琳，支援位
				]
			}]
		}, ],
	},
	{
		questsid: 3000038, //偷食的亡灵（N） 与【八云紫】一同前往【白玉楼】（N）
		type: 22,
		data: [{
			mapid: "M100103",
			difficulty: 2,
			groupid: 5, //白玉楼（普通）
			battledata: [{
				player: [
					{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
					{ cardid: "ATH0023", column: 2, row: 1 }, //八云紫，支援位
				]
			}]
		}, ],
	},
	{
		questsid: 3000039, //贤狼今泉 赠送【今泉影狼】两个【苹果】
		type: 50,
		data: [
			{ cardid: "ATH0083", equipmentid: 43105, count: 2, }, //苹果x3
		],
	},
	{
		questsid: 3000040, //请教物理知识 与【朝仓理香子】一同前往【境界裂口】
		type: 22,
		data: [{
			mapid: "M100092",
			difficulty: 2,
			groupid: 5, //境界裂口（普通）
			battledata: [{
				player: [
					{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
					{ cardid: "ATHZ012", column: 2, row: 1 }, //朝仓理香子，支援位
				]
			}]
		}, ],
	},
	{
		questsid: 3000201, //魔女的冶炼 使用【雾雨魔理沙】完成一次【炼金】
		type: 40,
		data: [
			{ blueprintid: 30011, }, //魔法道具
		],
	},
	{
		questsid: 3000501, //内有恶犬 前往【红魔馆前院】
		type: 10,
		data: [{
			mapid: "M100081",
			difficulty: 2,
			groupid: 5, //红魔馆前院
			battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
		}, ],
	},
	{
		questsid: 3000601, //门番的挑战 在一对一的情况下战胜【红美铃】
		type: 10,
		data: [{
			mapid: "M100081",
			difficulty: 2,
			groupid: 5, //红魔馆前院
			battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
		}, ],
	},
	{
		questsid: 3000701, //丢失的魔导书 退治【雾雨魔法店】的【雾雨魔理沙】
		type: 10,
		data: [{
			mapid: "M100062",
			difficulty: 2,
			groupid: 5, //雾雨魔法店
			battledata: [{ player: [{ cardid: "ATH0004", column: 1, row: 4 }] }] //大妖精，攻击位
		}, ],
	},
	{
		questsid: 3000801, //魔法实验 赠送【帕秋莉·诺蕾姬】一块【魔法石】
		type: 50,
		data: [
			{ cardid: "ATH0008", equipmentid: 42401, count: 1, }, //魔法石x1
		],
	},
	//3000901, //【日常】 储备飞刀 赠送【十六夜咲夜】一把【短剑】
	{
		questsid: 3000902, //添置工具 赠送【十六夜咲夜】一份【餐具】
		type: 50,
		data: [
			{ cardid: "ATH0009", equipmentid: 45101, count: 1, }, //餐具x1
		],
	},
	//3002001, //【日常】 真的没问题吗 退治【鬼火王】2只
	{
		questsid: 3002101, //反魂胃 八分饱 赠送【幽幽子】一份【团子】
		type: 50,
		data: [
			{ cardid: "ATH0021", equipmentid: 30005, count: 1, }, //团子x1
		],
	},
	//3002601 不散之宴，3002801 音乐之宴 移到后
	{
		questsid: 3002802, //道旁的夜店 赠送【米斯蒂娅·萝蕾拉】两批【煤炭】
		type: 50,
		data: [
			{ cardid: "ATH0028", equipmentid: 42202, count: 2, }, //煤炭x2
		],
	},
	//3002901, //【日常】 逃课的学生 前往【雾之湖】教训一下逃课的【琪露诺】
	//3003001, //【日常】 买卖阴谋 赠送【因幡帝】两批【蘑菇】
	{
		questsid: 3003101, //捣蛋的妖怪兔 击败【因幡帝】
		type: 10,
		data: [{
			mapid: "M100111",
			difficulty: 2,
			groupid: 5, //迷途竹林
			battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
		}, ],
	},
	//3003104, //【日常】 武装永远亭 赠送【铃仙·优昙华院·因幡】一支【旧式步枪】
	{
		questsid: 3003301, //你是笨蛋吗 与【蓬莱山辉夜】一同前往【竹林小屋（普通）】
		type: 10,
		data: [{
			mapid: "M100112",
			difficulty: 3,
			groupid: 5, //竹林小屋（困难）
			battledata: [{
				player: [
					{ cardid: "ATH0027", column: 1, row: 4 }, //莉格露·奈特巴格，攻击位
					{ cardid: "ATH0033", column: 1, row: 0 }, //蓬莱山辉夜，攻击位
				]
			}]
		}, ],
	},
	{
		questsid: 3003401, //你才是笨蛋 击败【蓬莱山辉夜（普通）】
		type: 10,
		data: [{
			mapid: "M100113",
			difficulty: 2,
			groupid: 5, //永远亭（普通）
			battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
		}, ],
	},
	{
		questsid: 3003402, //竹笋炒肉 赠送【藤原妹红】一份【竹笋】
		type: 50,
		data: [
			{ cardid: "ATH0034", equipmentid: 43103, count: 1, }, //竹笋x1
		],
	},
	{
		questsid: 3003501, //弄个大新闻 与【射命丸文】一同前往【守矢神社（普通）】
		type: 10,
		data: [{
			mapid: "M100051",
			difficulty: 2,
			groupid: 5, //守矢神社（普通）
			battledata: [{
				player: [
					{ cardid: "ATH0035", column: 1, row: 4 }, //射命丸文，攻击位
				]
			}]
		}, ],
	},
	{
		questsid: 3004201, //不安静的机器 退治【河童栖息地】的【侦查用飞行器II】8个
		type: 10,
		data: [{
				mapid: "M100031",
				difficulty: 2,
				groupid: 5, //河童栖息地
				battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
			},
			{
				mapid: "M100031",
				difficulty: 2,
				groupid: 5, //河童栖息地
				battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
			},
		],
	},
	{
		questsid: 3004301, //扳手不见了 前往【天狗的前哨】
		type: 10,
		data: [{
			mapid: "M100041",
			difficulty: 2,
			groupid: 5, //天狗的前哨
			battledata: [{ player: [{ cardid: "ATH0027", column: 1, row: 4 }] }] //莉格露·奈特巴格，攻击位
		}, ],
	},
	{
		questsid: 3004302, //河童制造 使用【河城荷取】完成一次【工程】
		type: 40,
		data: [
			{ blueprintid: 10011, }, //机械制造
		],
	},
	{
		questsid: 3004303, //齿轮回收 赠送【河城荷取】两个【零件】
		type: 50,
		data: [
			{ cardid: "ATH0043", equipmentid: 42501, count: 2, }, //零件x2
		],
	},
	//3004401, //【日常】 装备不足 赠送【犬走椛】一件【长刀】
	{
		questsid: 3006301, //眼球才不是玩具 与【古明地恋】一起退治【邪眼Σ】
		type: 10,
		data: [{
			mapid: "M100022",
			difficulty: 2,
			groupid: 5, //战车坟场
			battledata: [{
				player: [
					{ cardid: "ATH0063", column: 1, row: 4 }, //古明地恋，攻击位
				]
			}]
		}, ],
	},
	{
		questsid: 3006501, //照顾生意 使用【多多良小伞】完成一次【锻造】
		type: 40,
		data: [
			{ blueprintid: 20011, }, //装备锻造
		],
	},
	//3009201, //【日常】 妖精里的大小姐 退治【妖精】10只
	{
		questsid: 3009801, //制造书架 赠送【本居小铃】一批【木材】
		type: 50,
		data: [
			{ cardid: "ATH0098", equipmentid: 42101, count: 1, }, //木材x1
		],
	},
	{
		questsid: 3009901, //天体观测 与【宇佐见莲子】一同前往【御柱的墓场】
		type: 10,
		data: [{
			mapid: "M100052",
			difficulty: 2,
			groupid: 5, //御柱的墓场
			battledata: [{
				player: [
					{ cardid: "ATH0099", column: 1, row: 0 }, //宇佐见莲子，攻击位
					{ cardid: "ATH0100", column: 1, row: 4 }, //玛艾露贝莉·赫恩，攻击位
				]
			}]
		}, ],
	},
	{
		questsid: 3010001, //漆黑的妖怪 与【玛艾露贝莉·赫恩】一同前往【黑暗森林】
		type: 10,
		data: [{
			mapid: "M100071",
			difficulty: 2,
			groupid: 5, //黑暗森林
			battledata: [{
				player: [
					{ cardid: "ATH0099", column: 1, row: 0 }, //宇佐见莲子，攻击位
					{ cardid: "ATH0100", column: 1, row: 4 }, //玛艾露贝莉·赫恩，攻击位
				]
			}]
		}, ],
	},
	{
		questsid: 3100701, //修理是为了破坏 赠送【里香】两批【金属块】
		type: 50,
		data: [
			{ cardid: "ATHZ007", equipmentid: 42301, count: 2, }, //金属块x2
		],
	},
	{
		questsid: 3101401, //科学与幽灵 赠送【冈崎梦美】一个【罐装幽灵】
		type: 50,
		data: [
			{ cardid: "ATHZ014", equipmentid: 30004, count: 1, }, //罐装幽灵x2
		],
	},
	//3101501, //【日常】 能干的女仆 赠送【留琴】一批【布料】
	{
		questsid: 3002801, //音乐之宴 使用【米斯蒂娅·萝蕾拉】筹备一次【宴会】
		type: 30,
		data: [
			{ cardid: "ATH0028", type: 1 }, //米斯蒂娅·萝蕾拉 小宴
		],
	},
	{
		questsid: 3002601, //不散之宴 使用【伊吹萃香】筹备一次【宴会】
		type: 30,
		data: [
			{ cardid: "ATH0026", type: 1 }, //伊吹萃香 小宴
		],
	},
];

	const START_IP_default = "http://121.43.196.228:8070/TouHouServer/"; //储存默认API地址
	const RES_LIST_URL = "http://121.43.196.228:8070/TouHouServer/DownLoadList.txt";
	const desKey = '1XSB2DSWWA'.substr(0,8);
	const desKeyHex = CryptoJS.enc.Utf8.parse(desKey);
	const desIv = 'Areyoumy';
	const desIvHex = CryptoJS.enc.Utf8.parse(desIv);
	const contentTypeHeaders = {"Content-Type": "application/x-www-form-urlencoded"};
	const unloginSession = "UNLOGIN"; //未登录状态下的Session
	const spd = true; //是否开启加速
	 //判断是否支持webp格式图片 支持 返回true   不支持 返回false
	function check_support_webp() {
		//通过UserAgent获取火狐浏览器的版本
		let fxVer = /Firefox\/(\d+)(?:\.\d+)+/.exec(navigator.userAgent);
		if (fxVer && fxVer[1]>=65)
			return true;
		else
			return document.createElement('canvas').toDataURL('image/webp').indexOf('data:image/webp') == 0;
	}
	const imgExt = check_support_webp()?"webp":"png";
	const uiCSS = 
`body{
	padding: 0;
	margin: 0;
}
#dhbot{
	height: 100vh;
}
.accountBox{
	height: 22px;
}
.controlBox{
	height: 22px;
}
.logBox{
	height: calc(100% - 50px);
	border: 1px solid brown;
	overflow: auto;
}
.lbl-username::before
{
	content:"账号：";
}
.lbl-password::before
{
	content:"密码：";
}
.lbl-version::before
{
	content:"游戏版本：";
}
.lbl-maxLogs::before
{
	content:"日志最大长度：";
}
.accountBox label{
	margin-left: 5px;
}
.controlBox button,.controlBox label{
	margin-left: 5px;
}
.dhbot-log{
	margin: 0;
}
.dhbot-log dt::before{
	content:"▼ ";
}
.dhbot-log dd{
	margin-left: 5px;
}
.dhbot-log dd::before{
	content:"● ";
}
.cute,.enemys{
	max-height:100px;
}
.enemys{
	transform: rotateY(180deg);
}
.skin{
	max-height:200px;
}
.equipment{
	max-height:50px;
}
.menuicon{
	max-height:30px;
}`;
	var START_IP = GM_getValue("START_IP") || START_IP_default; //储存API地址
	var GameResArray = GM_getValue("GameRes") || []; //储存游戏数据
	var Session = GM_getValue("session") || unloginSession; //储存当前的Session
	var fengnasecondCheck = 0; //塞钱箱上次检查时间点
	var subkey = 0; //每次尾巴上跟着的数字
	var PlayerData = null; //用户数据
	var stop = false; //紧急停止用
	var maxLogs = parseInt(GM_getValue("maxLogs") || 100); //最多显示多少条日志

	const GobleMessage = {//官方的消息
		regis_gamename_tips : "姓名必须为2 ~6位中文或者4 ~12位字母。",
		regis_username_tips : "出入证号必须在6 ~12位之间，并且只能为数字或字母。",	
		regis_password_tips : "出入口令必须在6 ~12位之间，并且只能为数字或字母。",	
		regis_password_err : "出入口令两次输入不一致。",	
		regis_no : "由于游戏处于测试状态，因此暂停注册，开放时间请关注新浪微博：@妖怪山地下实验室 或 大家的幻想乡吧",	
		regis : "你已经注册过账号了，把机会留给别人吧。",	
		regis_over : "账号已经发放完毕，下次再来吧。",	
		shop_code_2 : "兑换码不存在。",	
		shop_code_3 : "兑换码已使用。",	
		shop_code_4 : "系统错误，请稍后重试。",	
		regis_gamename_repeat : "姓名已存在。",	
		regis_username_repeat : "出入证号已存在。",	
		login_version : "版本号过低，请下载最新客户端。",	
		login_state : "出入证已作废，禁止进入博丽大结界。",	
		login_state2 : "禁止进入博丽大结界。",	
		login_error : "账号或密码不正确。",	
		login_u_error : "账号不存在，请注意大小写。",	
		login_p_error : "密码错误，请注意大小写。",	
		login_unlogin : "登录信息失效，请重新登录。",	
		home_sqx_null : "里面什么都没有，待会再来看看吧……",	
		banquet_select_card : "请选择一名角色来筹办宴会",	
		banquet_no_foodmoney : "当前的金钱和食物不足以筹备这样的宴会。",	
		banquet_qy_bugou : "【妖精契约】不足，无法快速筹备。",	
		need_level : "需要等级",	
		get : "<color=green>{0}</color>获得[{1}x{2}]",	
		loyalty_add : "<color=green>{0}</color>好感度增加{1}",	
		card_add : "<color=green>{0}</color>成为了朋友",	
		not_gift : "此物品只能赠送给<color=green>{0}</color>",	
		sure_sell : "是否要出售",	
		sure_gift : "是否要赠送",	
		juesebugou : "请至少选择添加一名出击角色",	
		jueseditujinzhi : "此关卡禁止使用",	
		jueseyanhuijinzhi : "正在筹备宴会，无法出击",	
		ziyuanbugou : "当前食物或信仰储备无法完成该关卡。",	
		qjziyuanbugou : "食物或信仰不足，无法前进。",	
		qjduiwubudui : "队伍异常，无法前进。",	
		map_bootyn : "战利品：",	
		equip_type_1 : "体术",	
		equip_type_2 : "无",	
		equip_type_3 : "弹幕",	
		equip_range_1 : "近",	
		equip_range_2 : "中",	
		equip_range_3 : "远",	
		equip_range_4 : "远",	
		equip_range_5 : "远",	
		loginfirst_cj : "外面很危险，没有什么委托就不要出去了吧。",	
		loginfirst_sqx : "这是赛钱箱，来参拜的人会把香火钱放在里面，偶尔还会收到供奉的食物哦，不过最近来参拜的人越来越少了，是什么原因呢。",	
		loginfirst_yh : "恩？你说宴会啊，不行啦，筹备宴会需要钱和食物啦，而且宴会尽是招来奇怪的家伙，有机会给你认识一下，如果在这之前你没有被吃掉的话。",	
		loginfirst_zb : "出击治退妖怪之前都在这里进行整备，虽然没有什么东西，但是有所准备总是好的。",	
		loginfirst_qy : "这里原本是给前来参拜的人会挂绘马的地方，后来慢慢挂满了村民治退妖怪的委托，最近还有一些妖怪在上面留下一些委托，那么就先看看有什么委托吧。",	
		loginfirst_zz : "制造东西很麻烦呢，有什么需要的直接去你的世界买吧，当然我不会给你发工资的。",	
		loginfirst_sy : "如果你想学习幻想乡的知识，需要到人间之里的私塾，只有那里有老师呢，不过来回的路上有点危险，还是不要去得好。",	
		loginfirst_over : "既然你那么无聊，就去看看有什么简单的委托吧。",
	}
	const difficultyName = ["E","N","H","L"];//显示困难度的名字
	

	var $Spell, //游戏数据
		$Skin,
		$Quests,
		$Map,
		$Equipment,
		$Dialog,
		$Card,
		$Blueprint,
		$Banquet;
	
	//解密Base64编码的内容
	function unGzipBase64(base64String)
	{
		// 将UTF-8 ArrayBuffer转换回UTF-8字符串
		function uintToString(uintArray) {
			// var encodedString = String.fromCharCode.apply(null, uintArray); //这个写法因为参数个数限制，无法解析过长的字符串，因此改用循环
			let encodedStringArray = [];
			for (let i = 0,uL = uintArray.length;i<uL;i++)
			{
				encodedStringArray.push(String.fromCharCode(uintArray[i]));
			}
			let decodedString = decodeURIComponent(escape(encodedStringArray.join('')));
			return decodedString;
		}

		// 将Base64字符串转换为二进制字符串
		let decodedBase64Data = window.atob(base64String);
		// 将二进制字符串转换为字符数组
		let charData = decodedBase64Data.split('').map(function(x){return x.charCodeAt(0);}); 
		// 将数字数组转换成字节数组
		let binData = new Uint8Array(charData);
		// 解压到UTF-8 ArrayBuffer
		let utf8ArrayBuffer = pako.inflate(binData);
		let decodedData = uintToString(utf8ArrayBuffer);
		return decodedData;
	}
	//DES ECB模式加密
	function encryptByDESModeEBC(message){
		let encrypted = CryptoJS.DES.encrypt(message, desKeyHex, {iv: desIvHex});
		return encrypted.ciphertext.toString();
	}
	//DES ECB模式解密
	function decryptByDESModeEBC(ciphertext){
		let decrypted = CryptoJS.DES.decrypt({
				ciphertext: CryptoJS.enc.Hex.parse(ciphertext)
			}, desKeyHex, {iv: desIvHex});
		return decrypted.toString(CryptoJS.enc.Utf8);
	}
	class GameResInfo{
		constructor(Name,Url,Md5,type){
			this.Name = Name;
			this.Url = Url;
			this.Md5 = Md5;
			this.type = type;
			this.idname = null;
			this.data = null;
		};
		downloadString() {
			let _this = this;
			//console.log(log.add('开始下载 '+_this.Name));
			GM_xmlhttpRequest({
				url: _this.Url,
				method: "get",
				responseType: "text",
				onload: function(response) {
					let decodedData = unGzipBase64(response.responseText);
					let jo = null;
					try {
						jo = JSON.parse(decodedData);
					} catch (e) {
						console.error(log.add(_this.Name + " JSON 解析失败"), e, response);
						return;
					}
					_this.data = jo;
					console.log(log.add(_this.Name + ' 解析成功'));
					GM_setValue("GameRes",GameResArray);
					console.log(_this);
				},
				onerror: function(response) {
					console.error(log.add(_this.Name + " 下载失败，网络请求发生错误"), response);
					return;
				}
			})
		};
		id(id) { //以ID来获取对应的值
			return this.data.filter((item)=>{return item[this.idname] == id})[0];
		};
	}
	//强制更新数据
	function forceUpdate(){
		console.log(log.add("开始强制更新游戏数据，更新后需要刷新网页"));
		GM_xmlhttpRequest({
			url: RES_LIST_URL,
			method: "get",
			responseType: "text",
			onload: function(response) {
				try {
					let newGameResArray = response.responseText.split('#').slice(1).map((s)=>{
						let sa = s.split(',');
						return new GameResInfo(sa[0],sa[1],sa[2],sa[3]);
					});
					newGameResArray.forEach((nr)=>{
						for (let ri=0;ri<GameResArray.length;ri++)
						{
							if (GameResArray[ri].Name == nr.Name) //如果为已有的数据
							{
								if (GameResArray[ri].Md5 != nr.Md5) //如果先后Md5值不等
								{
									console.log(log.add(nr.Name + " 已更新"));
									GameResArray[ri] = null; //回收旧对象
									GameResArray[ri] = nr;
									nr.downloadString();
								}else
								{
									console.log(log.add(nr.Name + " 未更新"));
								}
								return;
							}
						}
						console.log(log.add("新增 " + nr.Name));
						GameResArray.push(nr);
						nr.downloadString();
					});
				} catch (e) {
					console.error(log.add("基础导航文件解析错误"),e);
				}
			},
			onerror: function(response) {
				console.error(log.add("网络请求发生错误，基础导航文件下载失败"), response);
				return;
			}
		})
	}

	class LogObj{
		constructor(ulDOM){
			this.dom = ulDOM;
			this.log = [];
		};
		clear(){
			this.log = [];
			let fragment = document.createDocumentFragment(); //创建节点用的临时空间
			fragment.appendChild(this.dom);
			this.dom.innerHTML = "";
			botBox.appendChild(fragment);
			this.dom.style.display = "none";
		};
		add(info,title = false){
			let outText = "";
			function advancedLog(obj)
			{ //输出各种设定的内容
				if (typeof(obj) == "string") //单纯文字信息
				{
					return document.createTextNode(obj);
				}else if (obj.tag)
				{
					let dom = document.createElement(obj.tag);
					if (obj.attribute && obj.attribute.length>0)
					{
						obj.attribute.forEach((a)=>{
							dom.setAttribute(a[0],a[1]);
						})
					}
					if (obj.innerHTML)
					{
						dom.innerHTML = obj.innerHTML;
					}
					//if (obj.className){dom.className = obj.className;}
					return dom
				}else
				{
					return false;
				}
			}
			//是否保持在滚动条底部
			//let keepBottom = (logBox.scrollTop + logBox.offsetHeight - logBox.scrollHeight) >= -20;

			this.log.push(info);
			let delTime = (this.log.length > maxLogs) ? (this.log.length - maxLogs) : 0;
			let fragment = document.createDocumentFragment(); //创建节点用的临时空间
			fragment.appendChild(this.dom);
			if (delTime >= 1) //删掉超长的旧消息
			{
				this.log.splice(0,delTime);
				for (let di=0;di<delTime;di++)
				{
					this.dom.children[0].remove();
				}
			}
			let li = this.dom.appendChild(document.createElement(title?"dt":"dd"));
			if (typeof(info) == "string") //单纯文字信息
			{
				li.appendChild(document.createTextNode(info));
				outText += info;
			}
			else if(info instanceof Array) //数组信息
			{
				info.forEach((i)=>{
					li.appendChild(advancedLog(i));
				});
				let consoleInfo = info.map(obj=>{
					if (typeof(obj) == "string") //单纯文字信息
					{
						return obj;
					}else if (obj.attribute != undefined)
					{
						let altstring = obj.attribute.filter(a=>{return a[0]=="alt";});
						if (altstring.length>0)
							{return altstring[0][1];}
						else
							{return "";}
					}else if (obj.tag == "br")
					{
						return "\n";
					}else
					{
						return "";
					}
				});
				outText += consoleInfo.join(" ");
			}
			logBox.appendChild(fragment);

			//if (keepBottom)
			//{
				logBox.scrollTop = logBox.scrollHeight;
			//}
			return outText;
		};
	}
	//储存和生成输出URL参数
	class formObj{
		constructor(){
			this.data = new URLSearchParams();
		};
		AddField(name,value){
			this.data.set(name, value);
		};
		DelField(name){
			this.data.delete(name);
		};
		toSearch(){
			return this.data.toString();
		};
		GetEncodeForm(){ //输出为大写的加密后的数据
			return encryptByDESModeEBC(this.toSearch()).toUpperCase();
		};
	}
	//获取随机数
	function randomNum(minNum, maxNum) {
		return parseInt(Math.random() * ( maxNum - minNum + 1 ) + minNum, 10);
	}
	//登陆后显示结果
	function loginCallBack(code)
	{
		switch (code)
		{
			case 100:
				console.log(log.add(GobleMessage.login_version));
				break;
			case 200:
				console.log(log.add(GobleMessage.login_u_error));
				break;
			case 201:
				console.log(log.add(GobleMessage.login_state));
				break;
			case 211:
				console.log(log.add(GobleMessage.login_state2));
				break;
			case 202:
				console.log(log.add(GobleMessage.login_p_error));
				break;
			case 101:
				console.log(log.add(GobleMessage.qjziyuanbugou));
				break;
			case 300:
				console.log(log.add(GobleMessage.qjduiwubudui));
				break;
			case 1:
			default:
		}
	}
	//所有网络请求的通用程序
	function link(url, form, callback)
	{
		if (stop) { console.warn(log.add("用户中断")); return; }
		if (!form) form = new formObj();
		let ranNum = randomNum(10000, 99999);
		subkey = (subkey == ranNum)?(subkey+1):ranNum;
		Session = GM_getValue("session");
		if (Session == unloginSession && url.indexOf("login")<0)
		{
			//未登陆状态进入其他程序时，如果有Session会导致返回错误
			;
		}else
		{
			form.AddField("session", Session);
			form.AddField("subkey", subkey);
		}
		GM_xmlhttpRequest({
			url: START_IP + url,
			method: "POST",
			data: "data=" + form.GetEncodeForm(),
			headers: contentTypeHeaders,
			onload: function(response) {
				let reTxt = response.response;
				let debugOnj = {url: url,form: form}
				try {
					debugOnj.json = JSON.parse(reTxt);
				} catch (e) {
					debugOnj.data = reTxt;
				}
				console.debug("请求和返回结果：",debugOnj);
				if (response.status != 200)
				{
					console.error(log.add(`服务器返回 ${response.status} 错误`),response);
					return;
				}else if (reTxt == unloginSession)
				{
					console.warn(log.add(GobleMessage.login_unlogin));
					if (url.indexOf("login")<0) //如果这不是登陆请求本身
					{
						GM_setValue("session", unloginSession);
						form.DelField("session");
						form.DelField("subkey");
						login(()=>{link(url, form, callback)}); //先请求登录
						return;
					}
				} else if (reTxt == "500" || reTxt == "error")
				{
					console.error(log.add(GobleMessage.shop_code_4));
					return;
				} else if (reTxt == "100")
				{
					console.error(log.add(GobleMessage.login_version));
					return;
				} else
				{
					let jsonData;
					try {
						jsonData = JSON.parse(reTxt);
					} catch (e) {
						console.error(log.add(url + " 获取到的不是JSON"), e, response);
						return;
					}
					let code = parseInt(jsonData.code,10);
					callback(jsonData ,code);
				}
			},
			onerror: function(response) {
				console.error(log.add(url + " 网络请求发生错误"),response);
			}
		});
	}
	//第一步登陆，获取真实地址
	function login(callback) {
		let nekoForm = new formObj();
		nekoForm.AddField("u", userInput.value);
		nekoForm.AddField("key", CryptoJS.SHA1("konakona" + passInput.value).toString());
		nekoForm.AddField("v", versionInput.value);
		link("logi/loginmain", nekoForm, (jsondata,code)=>{
			loginCallBack(code);
			if (code == 1)
			{
				START_IP = jsondata.ip + "TouHouServer/"; //更新服务器IP
				GM_setValue("START_IP", START_IP);
				loginMain(callback); //用新的IP重新登陆
			}
		});
	}
	//第二步登录，获取完整用户数据
	function loginMain(callback) {
		let nekoForm = new formObj();
		nekoForm.AddField("u", userInput.value);
		nekoForm.AddField("key", CryptoJS.SHA1("konakona" + passInput.value).toString());
		nekoForm.AddField("v", versionInput.value);
		link("logi/login", nekoForm, (jsondata,code)=>{
			loginCallBack(code);
			if (code == 1)
			{
				Session = jsondata.session; //更新Session
				GM_setValue("session",Session);
				PlayerData = jsondata;
				callback(jsondata);
			}
		});
	}
	//获取用户信息
	function refreshPlayerData(callback) {
		link("actor/playerdata", null, (jsondata,code)=>{
			if (code == 1)
			{
				if (!PlayerData) PlayerData = {};
				PlayerData.newsid = jsondata.newsid;
				PlayerData.userresources = jsondata.userresources;
				callback(jsondata);
			}
		});
	}
	//xx时间前转换方法 by @xioxin
	function timeDiff(time) {
		if (!time) {
			return '0秒';
		}
		var t = time;

		if (!t) {
			return '刚刚';
		}
		var f = [
			[31536000, '年'],
			[2592000, '个月'],
			[604800, '星期'],
			[86400, '天'],
			[3600, '小时'],
			[60, '分钟'],
			[1, '秒']
		];
		var c = 0;
		var retStr = "";
		for (var i in f) {
			var k = f[i][0];
			var v = f[i][1];
			c = Math.floor(t / k);
			if (0 != c) {
				retStr += c + v;
				t -= c * k;
			}
		}
		return retStr;
	};
	//检查塞钱箱（奉纳）
	function checkFengNa(callback) {
		if (PlayerData && PlayerData.userresources) { //已经有用户信息，直接检查
			let new_fengnasecond = parseInt(PlayerData.userresources.fengnasecond) + 
				(fengnasecondCheck > 0 ? Math.floor((new Date() - fengnasecondCheck) / 1000) : 0);
			console.log(log.add("塞钱箱已经累计了：" + timeDiff(new_fengnasecond),true));
		} else { //检查用户信息后重新检查赛钱箱
			refreshPlayerData(()=>{checkFengNa(callback);});
			return;
		}

		link("actor/fengna", null, (jsondata,code)=>{
			if (code == 1)
			{
				showRewardsGet(jsondata.settlement, "塞钱箱里有"); //显示获得的奖励
				PlayerData.userresources.fengnasecond = 0;
				fengnasecondCheck = new Date();
				callback(jsondata);
			}
		});
	}
	//显示获取奖励
	function showRewardsGet(settlement, prefix) {
		let logArr = [];
		if (settlement.gold > 0)
		{
			let logDom = {
				tag:"img",
				attribute:[
					["class","menuicon"],
					["src","Resources/scene/global/menu_gold." + imgExt],
					["alt","金钱"],
					["title","金钱"],
				]
			};
			logArr.push(logDom);
			logArr.push(settlement.gold);
		}
		if (settlement.faith > 0)
		{
			let logDom = {
				tag:"img",
				attribute:[
					["class","menuicon"],
					["src","Resources/scene/global/menu_faith." + imgExt],
					["alt","信仰"],
					["title","信仰"],
				]
			};
			logArr.push(logDom);
			logArr.push(settlement.faith);
		}
		if (settlement.food > 0)
		{
			let logDom = {
				tag:"img",
				attribute:[
					["class","menuicon"],
					["src","Resources/scene/global/menu_food." + imgExt],
					["alt","食物"],
					["title","食物"],
				]
			};
			logArr.push(logDom);
			logArr.push(settlement.food);
		}

		if (settlement.userEquipments.length > 0) //道具
		{
			logArr.push("道具：");
			settlement.userEquipments.forEach((item)=>{
				let itemName = $Equipment.id(item.equipmentid).equipmentname;
				let logDom = {
					tag:"img",
					attribute:[
						["class","equipment"],
						["src","Resources/equipment/"+item.equipmentid+"." + imgExt],
						["alt",itemName],
						["title",itemName],
					]
				};
				logArr.push(logDom);
				logArr.push("x" + item.addnumber);
			})
		}
		if (settlement.userCardDatas.length > 0) //皮肤，这里肯定会出错
		{
			logArr.push("人物：");
			settlement.userCardDatas.forEach((item)=>{
				let itemName = $Card.id(item.cardid).cardname + " - " + $Skin.id(item.addskinid).skinname;
				let logDom = {
					tag:"img",
					attribute:[
						["class","skin"],
						["src","Resources/char/charimg/"+item.addskinid+"." + imgExt],
						["alt",itemName],
						["title",itemName],
					]
				};
				logArr.push(logDom);
			})
		}
		if (logArr.length<1)
		{
			logArr.push("没有任何奖励");
		}
		logArr.unshift(prefix);
		console.info(log.add(logArr));
	}
	//接受任务
	function acceptQuests(qstArr, callback) {
		if (qstArr.length < 1) {
			callback();
			return;
		}
		let newQstArr = qstArr.concat();
		let thisQst = newQstArr.shift(); //删除新数组的第一个元素
		let QstId = thisQst.questsid; //当前任务ID

		//var qstGameData = $Quests.filter((q)=>{
		//	return parseInt(q.questsid,10) == QstId})[0]; //当前任务
		let qstGameData = $Quests.id(QstId);
		let qstName = qstGameData.name; //当前任务名
		console.log(log.add(`正在领取 ${QstId} ${qstGameData.cyclename}${qstName} ${qstGameData.true_content}。剩余 ${newQstArr.length} 个任务`,true));
		//发送领取数据
		
		let nekoForm = new formObj();
		nekoForm.AddField("questsid", QstId);
		link("quests/acceptQuests", nekoForm, (jsondata,code)=>{
			if (code == 1)
			{
                console.group("开始检查任务领取情况");
				checkQuest(0, ()=>{
					acceptQuests(newQstArr, callback); //任务检v查完成后继续下一个任务
				});
			}
		});

		function checkQuest(checkType, callback) {
			//checkType 为0表示看是否领取，checkType为1表示查看是否完成
			link("quests/questsData", null, dealCheck);
			function dealCheck(jsondata,code)
			{
				if (code == 1)
				{
					let qstRB = jsondata.userquests.filter((qst)=>{ //找到符合id的任务
						return (qst.questsid == QstId);
					})[0];
					if (qstRB == undefined) {
						console.error(log.add(QstId + " 任务不存在，请人为检查😰"));
						console.groupEnd();
						callback();
					} else {
						if (checkType == 0 && qstRB.complete != true) //添加当任务已经完成，只需要获取的时候也跳过
						{
							if (qstRB.acceptflag == "1") { //accept 的 True表示可以领取，False表示不能领取，所以改成了acceptflag 1 表示已领取
								console.log(log.add(`领取 ${QstId} ${qstName} 成功😄`));
								doQuest(callback);
							} else {
								console.error(log.add(`领取 %${QstId} ${qstName} 失败，请人为检查😰`));
								console.groupEnd();
								callback();
							}
						} else {
							if (qstRB.complete == true) {
								console.log(log.add(`任务 ${QstId} ${qstName} 完成，可领取奖励😄`));
								completeQuest(callback);
							} else {
								console.error(log.add(`任务 ${QstId} ${qstName} 仍未完成，请人为检查😰`));
								console.groupEnd();
								callback();
							}
						}
					}
				}
			}
		}
		//执行任务
		function doQuest(callback) {
			if (thisQst.type < 30) //战斗
			{
				console.log(log.add("任务为战斗类"));
				doBattleArray(thisQst.data, function() {
					//console.log(log.add("任务过图完成，开始检查是否完成任务"));
					checkQuest(1, callback);
				});
				return;
			} else if (thisQst.type < 40) //宴会
			{
				console.log(log.add("任务为宴会类"));
				banquetClear((code)=>{ //清理原来的宴会
					if (code == 1 && QstId == "3000006") { //如果是对象，就说明宴请成功了的，可以直接完成“宴请妖怪”这个无需求任务
						//console.log(log.add("宴会完成，开始检查是否完成任务"));
						checkQuest(1, callback);
					} else {
						redayBanquetArr(thisQst.data, function() {
							//console.log(log.add("宴会完成，开始检查是否完成任务"));
							checkQuest(1, callback);
						});
					}
				})
				return;
			} else if (thisQst.type < 50) //锻造
			{
				console.log(log.add("任务为锻造类"));
				equipmentDevelopArr(thisQst.data, function() {
					//console.log(log.add("锻造完成，开始检查是否完成任务"));
					checkQuest(1, callback);
				})
				return;
			} else if (thisQst.type < 60) //赠送
			{
				console.log(log.add("任务为赠送类"));
				equipmentGiftArr(thisQst.data, function() {
					//console.log(log.add("物品赠送完成，开始检查是否完成任务"));
					checkQuest(1, callback);
				})
				return;
			} else //未知
			{
				console.warn(log.add("未知的任务类型"));
				callback();
				return;
			}
		}
		//完成任务
		function completeQuest(callback) {
			let nekoForm = new formObj();
			nekoForm.AddField("questsid", QstId);
			link("quests/submitQuests", nekoForm, (jsondata,code)=>{
				if (code == 1)
				{
					showRewardsGet(jsondata.settlement, "获得任务奖励 ");
					console.groupEnd();
					callback();
				}
			});
		}
	}
	//开始执行一个战斗数组，batchIndex用来记录刷到多少了，防止重复刷图
	function doBattleArray(batArr, callback, batchIndex = 0, loop = false) {
		let thisBat = batArr[batchIndex];
		if (batchIndex > batArr.length || thisBat == undefined)
		{
			callback();
			return;
		}
		//用于把结构化战斗人物数据转为post格式
		function playerToString(playersData) {
			return playersData.map(function(item) {
				return [item.cardid,item.column,item.row].join(",");
			}).join(";");
		}
		console.info(log.add("开始刷第" + (batchIndex + 1) + "张图"));

		//loop时需要重复进入地图，所以不能写在doBattleArray里，得另外来一个函数。
		enterTheMap(thisBat, loop, ()=>{
			++batchIndex; //batchIndex增加1
			if (loop) GM_setValue("batchIndex", batchIndex); //如果是循环的，每次都记录新的batchIndex
			doBattleArray(batArr, callback, batchIndex, loop); //进入下一图
		})

		function enterTheMap(bat, loop, callback) {
			//进图的队伍数据
			let players = bat.battledata[0].player;
			let nekoForm = new formObj();
			nekoForm.AddField("data", playerToString(bat.battledata[0].player));
			nekoForm.AddField("mapid", bat.mapid);
			nekoForm.AddField("groupid", bat.groupid);
			nekoForm.AddField("difficulty", bat.difficulty);
			link("map/mapdata", nekoForm, (jsondata,code)=>{
				if (code == 1)
				{
					//翻译角色
					let playersStr = players.map((p)=>{return $Card.id(p.cardid).cardname;});
					let map = $Map.id(bat.mapid);
					let mapStr = map.groupname + "-" + map.mapname + difficultyName[bat.difficulty-1] + "，共 " + map.itemcount + " 面";

					let logArr = [];
					players.forEach((item)=>{
						let itemName = $Card.id(item.cardid).cardname;
						let logDom = {
							tag:"img",
							attribute:[
								["class","cute"],
								["src","Resources/char/charcute/"+item.cardid+"01." + imgExt],
								["alt",itemName],
								["title",itemName],
							]
						};
						logArr.push(logDom);
					})
					logArr.push(" 进入了 " + mapStr);
					console.group(log.add(logArr,true));

					setTimeout(()=>{
						battleStep(bat, null, (bootyn)=>{
							if (loop && bootyn > 0) //如果重复，且剩余大于0
							{ //继续进入此关
								enterTheMap(bat, loop, callback);
							} else //如果不重复，直接进入下一图
							{
								//console.log("非循环刷图模式模式，进入下一图");
								callback();
								return;
							}
						});
					}, 1000); //进图延时一秒
				}else
				{
					console.log(log.add("进图失败"));
					loginCallBack(code);
					callback();
				}
			});

			function battleStep(bat, stepIndex = 0, callback) {
				let thisBatData = bat.battledata[stepIndex] || bat.battledata[bat.battledata.length - 1]; //如果没有这个序号的地图数据，就使用最后一个
				if (thisBatData.exit) { callback(); return; } //遇到exit结束这一关
				let nekoForm = new formObj();
				nekoForm.AddField("data", playerToString(bat.battledata[0].player));
				nekoForm.AddField("or", thisBatData.or || 0);
				if (thisBatData.equipmentid)
				{ nekoForm.AddField("equipmentid", thisBatData.equipmentid); }
				nekoForm.AddField("iskszd", 0); //测试服有的快速战斗
				link("battle/battledata", nekoForm, (jsondata,code)=>{
					if (code == 1)
					{
						dealBattle(jsondata.battledata); //处理战斗数据
					}else
					{
						console.log(log.add("进入战斗失败"));
						loginCallBack(code);
						callback();
					}
				});
	
	
				function dealBattle(bd) {
					//计算等待时间
					let delay = bd.battleData.reduce(function(preValue, cur) {
						var de = 0;
						if (cur.cmd == "S") {
							de += spd ? 300 : 1000;
						} else if (cur.cmd == "B") {
							de += spd ? 300 : 1000;
						} else if (cur.cmd == "D") {
							var unattack = cur.unattack;
							var atktype = unattack.length > 0 ? unattack[0].attacktype : 0;
							if (atktype == 3001) //弹幕比较慢
								de += spd ? 600 : 2000;
							else
								de += spd ? 300 : 1000;
						}
						return preValue + de;
					}, 5000);
					let roundCount = bd.battleData.filter((item)=>{
						return item.cmd == "R";
					}).pop().rounds; //获取回合数，所有rounds里面最后一个的值
					let result = bd.battleResult; //战斗结果
					let win = result.result == "1";
					let mapitemid = bd.itemData.mapitemid;
					let stepIndexGuess = mapitemid.substr(mapitemid.length - 1, 1); //当前是第几面
	
					let userEquipments = bd.battleResult.settlement.userEquipments;
	
					let bTime = new Date();
					bTime.setMilliseconds(bTime.getMilliseconds() + delay); //计算战斗结束是什么时间
	
					let logArr = []; //储存log
					//if (spd) logArr.push("🚀"); //是否三倍速模式
					logArr.push(stepIndexGuess + "面，"); //面数
					logArr.push("战斗" + roundCount + "回合后"); //战斗总回合数
					logArr.push(win ? "😄胜利" : "😰失败"); //战斗总回合数
					logArr.push(`EXP+${result.userCardDatas[0].addexp}，`); //增加经验
					let hpPC = parseInt(result.userCardDatas[0].hp,10)/parseInt(bd.player[0].hpmax,10)*100; //血量百分比浮点数
					logArr.push(`HP剩余${hpPC.toFixed(hpPC == 100 ? 0 : 2)}%，`); //血量百分比
					logArr.push(`等待${(delay / 1000).toFixed(1)}秒（${bTime.getHours()}:${bTime.getMinutes()}:${bTime.getSeconds()}结束）。`); //等待时间
					logArr.push({tag:"br"}); //换行
					logArr.push("敌人");
					bd.enemys.forEach((item)=>{
						let logDom = {
							tag:"img",
							attribute:[
								["class","enemys"],
								["src","Resources/char/charcute/"+item.skinid+"." + imgExt],
								["alt",item.enemyid],
								["title",item.enemyid],
							]
						};
						logArr.push(logDom);
					})

					console.log(log.add(logArr));

					showRewardsGet(bd.battleResult.settlement, "战斗掉落 ");
	
					//进行下一步操作
					setTimeout(()=>{
						if (parseInt(result.nextFlag,10) > 0) { //如果有下一面，进入下一面
							battleStep(bat, ++stepIndex, callback);
							return;
						} else {
							let bootyn = parseInt(bd.userMap.bootyn,10);
							console.log(log.add("本图材料剩余 "+bootyn+" 可刷"));
							console.groupEnd();
							callback(bootyn);
						}
					}, delay); //延时
				}
			}
		}
	}

	//清除之前可能存在的宴会
	function banquetClear(callback) {
		banquetFastreday(()=>{
			banquetSubmit(callback);
		})
	}
	//快速筹备
	function banquetFastreday(callback) {
		link("banquet/fastreday", null, (jsondata,code)=>{
			if (code == 1)
			{
				let logArr = [];
				logArr.push("快速筹备消耗");
				let itemName = $Equipment.id(jsondata.userequipment.equipmentid).equipmentname;
				let logDom = {
					tag:"img",
					attribute:[
						["class","equipment"],
						["src","Resources/equipment/"+jsondata.userequipment.equipmentid+"." + imgExt],
						["alt",itemName],
						["title",itemName],
					]
				};
				logArr.push(logDom);
				logArr.push((jsondata.userequipment.addnumber>=0?"+":"") + jsondata.userequipment.addnumber);
				console.log(log.add(logArr));
			}else if (code == 101)
			{
				console.log(log.add("快速筹备失败"));
			}
			callback(code);
		});
	}
	//举行宴会
	function banquetSubmit(callback) {
		link("banquet/submit", null, (jsondata,code)=>{
			if (code == 1)
			{
				showRewardsGet(jsondata.settlement, "宴会宾客");
			}else if (code == 101)
			{
				console.log(log.add("举行宴会失败"));
			}
			callback(code);
		});
	}
	//宴会准备数组
	function redayBanquetArr(baqArr, callback) {
		if (baqArr.length < 1) {
			callback();
			return;
		}

		var newBaqArr = baqArr.concat();
		var thisBaq = newBaqArr.shift(); //删除新数组的第一个元素

		let nekoForm = new formObj();
		nekoForm.AddField("cardid", thisBaq.cardid);
		nekoForm.AddField("type", thisBaq.type);
		link("banquet/reday", nekoForm, (jsondata,code)=>{
			if (code == 1)
			{
				let logArr = [];
				let itemName = $Card.id(thisBaq.cardid).cardname;
				let logDom = {
					tag:"img",
					attribute:[
						["class","cute"],
						["src","Resources/char/charcute/"+thisBaq.cardid+"01." + imgExt],
						["alt",itemName],
						["title",itemName],
					]
				};
				logArr.push(logDom)
				logArr.push(` 执行了一次 ${$Banquet.id(thisBaq.type).name}`);
				console.log(log.add(logArr));
				banquetFastreday(()=>{ //执行快速筹备
					banquetSubmit(()=>{ //开始宴会
						redayBanquetArr(newBaqArr, callback); //准备下一次宴会
					});
				})
			}else if (code == 101)
			{
				console.log(log.add("准备宴会失败"));
				redayBanquetArr(newBaqArr, callback); //准备下一次宴会
			}
		});
	}
	//锻造数组执行
	function equipmentDevelopArr(devArr, callback) {
		if (devArr.length < 1) {
			callback();
			return;
		}
		var newDevArr = devArr.concat();
		var thisDev = newDevArr.shift(); //删除新数组的第一个元素

		let nekoForm = new formObj();
		nekoForm.AddField("blueprintid", thisDev.blueprintid);
		link("equipment/develop", nekoForm, (jsondata,code)=>{
			if (code == 1)
			{
				let blueprint = $Blueprint.id(thisDev.blueprintid);
				showRewardsGet(jsondata.settlement, "锻造 " + blueprint.typename + " - " + blueprint.name + " 获得");
				equipmentDevelopArr(newDevArr, callback); //开始锻造下一个
			}
		});
	}
	//赠送物品数组执行
	function equipmentGiftArr(giftArr, callback) {
		if (giftArr.length < 1) {
			callback();
			return;
		}
		let newGifArr = giftArr.concat();
		let thisGif = newGifArr.shift(); //删除新数组的第一个元素

		let nekoForm = new formObj();
		nekoForm.AddField("equipmentid", thisGif.equipmentid);
		nekoForm.AddField("cardid", thisGif.cardid);
		nekoForm.AddField("count", thisGif.count);
		link("equipment/gift", nekoForm, (jsondata,code)=>{
			if (code == 1)
			{
				let logArr = ["赠送 "];
				let itemName = $Equipment.id(thisGif.equipmentid).equipmentname;
				let logDom = {
					tag:"img",
					attribute:[
						["class","equipment"],
						["src","Resources/equipment/"+thisGif.equipmentid+"." + imgExt],
						["alt",itemName],
						["title",itemName],
					]
				};
				logArr.push(logDom);
				logArr.push("x" + thisGif.count);
				logArr.push("给");
				let itemName2 = $Card.id(thisGif.cardid).cardname;
				let logDom2 = {
					tag:"img",
					attribute:[
						["class","cute"],
						["src","Resources/char/charcute/"+thisGif.cardid+"01." + imgExt],
						["alt",itemName2],
						["title",itemName2],
					]
				};
				logArr.push(logDom2);
				if (parseInt($Equipment.id(thisGif.equipmentid).type,10)<3 && !jsondata.usercardequipment)
				{
					logArr.push("失败，可能已经没有该武器/防具库存。");
				}
				//jsondata.usercarddata
				console.log(log.add(logArr));
				equipmentGiftArr(newGifArr, callback); //开始赠送下一个
			}
		});
	}

	//初始化
	document.head.innerHTML = "";
	document.body.innerHTML = "";
	const fragment = document.createDocumentFragment(); //创建节点用的临时空间
	const botBox = fragment.appendChild(document.createElement("div")); //显示操作框架的DOM
	botBox.id = "dhbot";
	const accountBox = botBox.appendChild(document.createElement("div")); //账号的DOM
	accountBox.className = "box-line accountBox";
		const userLabel = accountBox.appendChild(document.createElement("label")); //用户名的label
		userLabel.className = "lbl-username";
			const userInput = userLabel.appendChild(document.createElement("input")); //密码的label
			userInput.id = "dhbot-username";
			userInput.value = GM_getValue("username") || "";
			userInput.onchange = function()
			{
				GM_setValue("username",this.value);
			}
		const passLabel = accountBox.appendChild(document.createElement("label")); //用户名的label
		passLabel.className = "lbl-password";
			const passInput = passLabel.appendChild(document.createElement("input")); //密码的label
			passInput.id = "dhbot-password";
			passInput.type = "password";
			passInput.value = GM_getValue("password") || "";
			passInput.onchange = function()
			{
				GM_setValue("password",this.value);
			}
		const versionLabel = accountBox.appendChild(document.createElement("label")); //用户名的label
		versionLabel.className = "lbl-version";
			const versionInput = versionLabel.appendChild(document.createElement("input")); //版本的label
			versionInput.id = "dhbot-version";
			versionInput.value = GM_getValue("version") || "1.0.2.6";
			versionInput.onchange = function()
			{
				GM_setValue("version",this.value);
				START_IP = START_IP_default; //版本更新也重置开始路径
				GM_setValue("START_IP", START_IP_default);
			}
	const controlBox = botBox.appendChild(document.createElement("div")); //控制按钮的DOM
	controlBox.className = "box-line controlBox";
		const updateButton = controlBox.appendChild(document.createElement("button")); //强制更新数据的按钮
		updateButton.appendChild(document.createTextNode("强制更新数据"));
		updateButton.onclick = forceUpdate;
		const dailyButton = controlBox.appendChild(document.createElement("button")); //做日常任务
		dailyButton.appendChild(document.createTextNode("做日常任务"));
		dailyButton.onclick = function(){
			stop = false;
			checkFengNa(()=>{ //先检查赛钱箱，然后开始接受任务
				acceptQuests(QuestsArr, ()=>{ //做任务列表
					console.log(log.add("日常任务执行完毕"));
				})}
			)};
		const loopButton = controlBox.appendChild(document.createElement("button")); //循环刷图
		loopButton.appendChild(document.createTextNode("循环刷材料"));
		loopButton.onclick = function(){
			stop = false;
			let batchIndex = parseInt(GM_getValue("batchIndex") || 0,10);
			batchIndex = batchIndex % batchArr.length; //求余，防止已经超出了地图最后一个
			doBattleArray(batchArr, ()=>{
				console.warn(log.add("地图全都刷完了")); 
			}, batchIndex, true);
		};
		const breakButton = controlBox.appendChild(document.createElement("button")); //强制更新数据的按钮
		breakButton.appendChild(document.createTextNode("中断操作"));
		breakButton.onclick = ()=>{stop = true};
		const maxLogsLabel = controlBox.appendChild(document.createElement("label")); //用户名的label
		maxLogsLabel.className = "lbl-maxLogs";
			const maxLogsInput = maxLogsLabel.appendChild(document.createElement("input")); //版本的label
			maxLogsInput.id = "dhbot-maxLogs";
			maxLogsInput.type = "number";
			maxLogsInput.min = 1;
			maxLogsInput.value = maxLogs;
			maxLogsInput.onchange = function()
			{
				GM_setValue("maxLogs",this.value);
				maxLogs = parseInt(this.value,10);
			}
	const logBox = botBox.appendChild(document.createElement("div")); //日志的DOM
	logBox.className = "box-line logBox";
	const logUl = logBox.appendChild(document.createElement("dl")); //日志的DOM
	logUl.className = "dhbot-log";
	const log = new LogObj(logUl);

	document.body.appendChild(fragment); //将生成的所有内容都添加到界面
	document.title = GM_info.script.name;
	GM_addStyle(uiCSS);

	//加载一个游戏数据，并添加搜索用的名称
	function loadGameResInfo(name,idname)
	{
		let jsonRes = GameResArray.filter((r)=>{return r.Name == name})[0];
		if (!jsonRes)
		{
			console.error(log.add(name + " 未获取到游戏数据，需要更新"));
			return;
		}
		let res = new GameResInfo(jsonRes.Name,jsonRes.Url,jsonRes.Md5,jsonRes.type);
		res.data = jsonRes.data;
		res.idname = idname;
		return res;
	}
	//将游戏数据分别读取
	//$Spell = loadGameResInfo("Spell","spellid");
	$Skin = loadGameResInfo("Skin","skinid");
	$Quests = loadGameResInfo("Quests","questsid");
	$Map = loadGameResInfo("Map","mapid");
	$Equipment = loadGameResInfo("Equipment","equipmentid");
	//$Dialog = loadGameResInfo("Dialog","dialogid"); //不止一个ID
	$Card = loadGameResInfo("Card","cardid");
	$Blueprint = loadGameResInfo("Blueprint","blueprintid");
	$Banquet = loadGameResInfo("Banquet","type");
})();